-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-139640: Fix swallowing syntax warnings in different modules #139642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-139640: Fix swallowing syntax warnings in different modules #139642
Conversation
Revert pythonGH-131993. Fix swallowing some syntax warnings in different modules if they accidentally have the same message and are emitted from the same line. ast.parse() no longer emits syntax warnings for return/break/continue in finally (see PEP-765) -- they are only emitted during compilation.
2fa4266
to
c04d874
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AST changes are LGTM.
Thank you Serhiy.
Would it be possible to avoid the side effect of delaying the PEP 765 syntax warnings to the code generation stage? Emitting those syntax warnings during AST construction is one of the key reasons I was comfortable suggesting turning them off globally in #139658 when static code analysis was in use. |
Only if you are fine with double warnings in REPL or other places that use There are three kinds of warnings, by the emitter:
So, you already see not all warnings if you only use |
Actually I think this was a deliberate decision, we want this to happen during static analysis. Can we add a kwarg to ast.parse to tell it whether to emit syntax warnings or not? |
We can, but
It is safer to disable that warning by default in |
The default should be to give the warning. Turn it off in cpython when we know that the code was just ast.parse'ed (rather than an ast given by the user - we do know that). |
What is the name of the option you propose to add? |
Could be |
No, because it should not control all warnings. Maybe |
Why not all warnings? |
Revert GH-131993.
Fix swallowing some syntax warnings in different modules if they accidentally have the same message and are emitted from the same line.
ast.parse() no longer emits syntax warnings for
return/break/continue in finally (see PEP-765) -- they are only emitted during compilation.